package org.czl;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] dp = new int[n];
        dp[0] = 1;
        int l = 0; int r = 0;
        for (int i = 1; i < n; i++){
            int nextL = 2 * dp[l];
            int nextR = 3 * dp[r];
            dp[i] = Math.min(nextL, nextR);
            if (dp[i] == nextL) {
                l++;
            }
            if (dp[i] == nextR) {
                r++;
            }
        }
        System.out.println(dp[n - 1]);
    }

}
